/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main;

import java.io.File;

import lejos.nxt.SensorPort;
import lejos.nxt.Sound;
import lejos.nxt.TouchSensor;

/**
 * If the Button has been touched
 * @author Max
 */
public class MagicButton implements Runnable
{

    TouchSensor magicButton;
    Engine engine;
    SensorEngine rotationSensor;

    public MagicButton(Engine en, SensorEngine se)
    {
        magicButton = new TouchSensor(SensorPort.S3);
    }

    public void run()
    {
        do
        {
            try
            {
                Thread.sleep(10);
            } catch (InterruptedException ex)
            {
                Thread.currentThread().interrupt();
            }
            if (magicButton.isPressed())
            {
                Sound.playSample(new File("chewy1.wav"), 100);
            }
        } while (!Thread.currentThread().isInterrupted());

    }
}
